package cn.itsource.hrm.controller;

import cn.itsource.hrm.doc.CourseDoc;
import cn.itsource.hrm.domain.Course;
import cn.itsource.hrm.query.CourseQuery;
import cn.itsource.hrm.service.ISearchService;
import cn.itsource.hrm.util.AjaxResult;
import cn.itsource.hrm.util.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SearchController {
    @Autowired
    private ISearchService searchService;
    @RequestMapping(value = "/search/save",method = RequestMethod.POST)
    public AjaxResult save(@RequestBody CourseDoc doc){
        searchService.save(doc);
        return AjaxResult.me();
    }

    @RequestMapping(value = "/search/delete",method = RequestMethod.POST)
    public AjaxResult delete(@RequestBody CourseDoc doc){
        searchService.delete(doc);
        return AjaxResult.me();
    }

    //前台展示(根据条件查询)
    @RequestMapping(value = "/es/searchCourse",method = RequestMethod.POST)
    public AjaxResult searchCourse(@RequestBody CourseQuery courseQuery){
        PageList coursePageList=searchService.searchCourse(courseQuery);
        return AjaxResult.me().setResultObj(coursePageList);
    }
}
